package com.wingy.mysimpleplaydemo;

import android.content.Intent;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class mySimplePlayDemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_simple_play_demo);

        Button button1 = (Button) findViewById(R.id.button_start);
        Button button2 = (Button) findViewById(R.id.button_stop);
        button1.setOnClickListener(startIt);
        button2.setOnClickListener(stopIt);
    }

    private View.OnClickListener startIt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startService(new Intent(mySimplePlayDemoActivity.this, MusicService.class));
        }
    };

    private View.OnClickListener stopIt = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            stopService(new Intent(mySimplePlayDemoActivity.this, MusicService.class));
            finish();
        }
    };
}